function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}
$(function () {
    var a = GetQueryString('email');
    if (a != null) {
        $(".content_1").hide();
        $("#step2 .left,#step2 .right,#step2 .number,#step3 .left,#step3 .right,#step3 .number").addClass("bg_blue");
        $("li#step2 .text,li#step3 .text").addClass("text_blue");
        $(".content_3").show();
    }

})
$("#send,#Resend").click(function () {
    var accountNumber = $("#mobile").val();
    var params = {
        'apiKey': 'api_post_getUsersByPhone',
        'email': accountNumber,
        'passwordUrl': "http://127.0.0.1:5501/ForgetPassword.html?email=" + accountNumber,
        'deviceType': 'DIC_DEVICE_TYPE_1',
        contentType: "application/json;charset=utf-8",
        datatype: 'json'
    };

    console.log(accountNumber);
    $.ajax({
        type: "POST",
        url: "http://192.168.1.182:8080/d_easy/deasy/api",
        data: params,
        dataType: "json",
        success: function (data) {
        }
    })
})

$("#submit_2").click(function () {
    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = window.location.search.substr(1).match(reg);  //匹配目标参数
        if (r != null) return unescape(r[2]); return null; //返回参数值
    }
    var accountNumber = getUrlParam('email');
    var pd = $("#code_input4").val();
    console.log(accountNumber);
    console.log(pd);
    var params = {
        'apiKey': 'api_post_updatePassWord',
        'password': pd,
        'email': accountNumber,
        'deviceType': 'DIC_DEVICE_TYPE_1',
        contentType: "application/json;charset=utf-8",
        datatype: 'json'
    };

    $.ajax({
        type: "POST",
        url: "http://192.168.1.182:8080/d_easy/deasy/api",
        data: params,
        dataType: "json",
        success: function (data) {
        }
    })
})



$('.get_code').on('click', function () {
    var that = $(this)
    var timeo = 60;
    var timeStop = setInterval(function () {
        timeo--;
        if (timeo > 0) {
            that.text('重新获取(' + timeo + 's)');
            that.attr('disabled', 'disabled');//禁止点击
        } else {
            timeo = 60;//当减到0时赋值为60
            that.text('获取验证码');
            clearInterval(timeStop);//清除定时器
            that.removeAttr('disabled');//移除属性，可点击
        }
    }, 1000)
})

var verifyCode = new GVerify("v_container");

document.getElementById("my_button").onclick = function () {
    var res = verifyCode.validate(document.getElementById("code_input").value);
    if (res) {
        $(".content_1").hide();
        $(".accountLogin").show();
        $(".content_2").show();
        $("#step2 .left,#step2 .right,#step2 .number").addClass("bg_blue");
        $("li#step2 .text").addClass("text_blue");
    } else {
        alert("验证码错误");
    }
}

document.getElementById("verify_2").onclick = function () {
    $(".verify_code").hide();
    $(".submit_1").hide();
    $(".send_email").hide();
    $(".send").show();
}
document.getElementById("verify_1").onclick = function () {
    $(".send").hide();
    $(".send_email").hide();
    $(".verify_code").show();
    $(".submit_1").show();
}
document.getElementById("send").onclick = function () {
    $(".phone_verify").hide();
    $(".e-mail_verify").hide();
    $(".send").hide();
    $(".send_email").show();
}

document.getElementById("submit_1").onclick = function () {
    $(".content_2").hide();
    $("#step3 .left,#step3 .right,#step3 .number").addClass("bg_blue");
    $("li#step3 .text").addClass("text_blue");
    $(".content_3").show();
}
document.getElementById("submit_2").onclick = function () {
    $(".content_3").hide();
    $("#step4 .left,#step4 .right,#step4 .number").addClass("bg_blue");
    $("li#step4 .text").addClass("text_blue");
    $(".content_4").show();
}